package com.qf.scheduler;

import com.qf.job.MyJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class MyConScheduler {

    public static void main(String[] args) throws SchedulerException {
//        1 创建调度器
        Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
//        2 编写 触发器
        CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("cron2", "group1")
                .withSchedule(CronScheduleBuilder.cronSchedule("0/2 * 9-12 * * ?"))
                .build();
//        3  编写 jobDetail
        JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("mycon1", "group1").build();
//        4 将触发器和任务添加到调度器里
        defaultScheduler.scheduleJob(jobDetail, trigger);
//        5 启动
        defaultScheduler.start();
    }
}
